/*
 * BestImageShow.java
 *
 * Created on Jul 22, 2009, 3:06:29 PM
 */

package geneticpolyimage;

import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 * Form to show best image founded, target image and difference image
 * @author igor & mattia
 */
public class ImageShow extends javax.swing.JFrame {

    /** Creates new form BestImageShow */
    public ImageShow() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelTargetImage = new javax.swing.JPanel();
        jPanelBestImage = new javax.swing.JPanel();
        jPanelDiffImage = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        javax.swing.GroupLayout jPanelTargetImageLayout = new javax.swing.GroupLayout(jPanelTargetImage);
        jPanelTargetImage.setLayout(jPanelTargetImageLayout);
        jPanelTargetImageLayout.setHorizontalGroup(
            jPanelTargetImageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 41, Short.MAX_VALUE)
        );
        jPanelTargetImageLayout.setVerticalGroup(
            jPanelTargetImageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanelBestImageLayout = new javax.swing.GroupLayout(jPanelBestImage);
        jPanelBestImage.setLayout(jPanelBestImageLayout);
        jPanelBestImageLayout.setHorizontalGroup(
            jPanelBestImageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 35, Short.MAX_VALUE)
        );
        jPanelBestImageLayout.setVerticalGroup(
            jPanelBestImageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanelDiffImageLayout = new javax.swing.GroupLayout(jPanelDiffImage);
        jPanelDiffImage.setLayout(jPanelDiffImageLayout);
        jPanelDiffImageLayout.setHorizontalGroup(
            jPanelDiffImageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
        );
        jPanelDiffImageLayout.setVerticalGroup(
            jPanelDiffImageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 39, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanelTargetImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelDiffImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelBestImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelBestImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanelDiffImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanelTargetImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Display best image found
     * @param image image to display
     */
    public void printBestImage(BufferedImage image){
        jPanelBestImage.setLayout(new BorderLayout());
        //jPanelImage.setPreferredSize(new Dimension(300, 300));
        jPanelBestImage.removeAll();
        jPanelBestImage.setSize(image.getWidth(), image.getHeight());
        //BufferedImage image  = status.thebest.getImage();
        ImageIcon icon = new ImageIcon(image);
        this.setIconImage(image);
        JLabel label = new JLabel();
        label.setIcon(icon);
        jPanelBestImage.add(label);
        //jPanel1.add(chartPanel, BorderLayout.CENTER);
        jPanelBestImage.validate();
        jPanelBestImage.repaint();
    }
    /**
     * Display difference image
     * @param image image to display
     */
    public void printDiffImage(BufferedImage image){
        jPanelDiffImage.setLayout(new BorderLayout());
        //jPanelImage.setPreferredSize(new Dimension(300, 300));
        jPanelDiffImage.removeAll();
        jPanelDiffImage.setSize(image.getWidth(), image.getHeight());
        //BufferedImage image  = status.thebest.getImage();
        ImageIcon icon = new ImageIcon(image);
        this.setIconImage(image);
        JLabel label = new JLabel();
        label.setIcon(icon);
        jPanelDiffImage.add(label);
        //jPanel1.add(chartPanel, BorderLayout.CENTER);
        jPanelDiffImage.validate();
        jPanelDiffImage.repaint();
    }
    /**
     * Display target image
     * @param image image to display
     */
    public void printTargetImage(Icon icon){
        jPanelTargetImage.setLayout(new BorderLayout());
        //jPanelImage.setPreferredSize(new Dimension(300, 300));
        jPanelTargetImage.removeAll();
        jPanelTargetImage.setSize(icon.getIconWidth(), icon.getIconHeight());
        //BufferedImage image  = status.thebest.getImage();
        
        JLabel label = new JLabel();
        label.setIcon(icon);
        jPanelTargetImage.add(label);
        //jPanel1.add(chartPanel, BorderLayout.CENTER);
        jPanelTargetImage.validate();
        jPanelTargetImage.repaint();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanelBestImage;
    private javax.swing.JPanel jPanelDiffImage;
    private javax.swing.JPanel jPanelTargetImage;
    // End of variables declaration//GEN-END:variables

}
